package cn.quevo.cube.provide.define.validate.impl;

import cn.quevo.common.exception.CustomException;
import cn.quevo.common.lang.StringUtils;
import cn.quevo.cube.provide.define.entity.dto.CubeColumnDto;
import cn.quevo.cube.provide.define.validate.AbstractColumnTypeValidate;
import cn.quevo.cube.provide.define.validate.ColumnTypeValidate;
import cn.quevo.cube.provide.define.validate.tools.ColumnExtTool;
import cn.quevo.cube.provide.exception.response.ColumnExceptionResponse;

/**
 * 枚举类型验证
 *
 * @author July july_sky@foxmail.com
 * @version 1.0
 * @date 2018/12/14 4:58 PM
 * @Copyright 湘豫（北京）科技有限公司版权所有.All Rights Reserved.
 */
public class EnumValidate extends AbstractColumnTypeValidate implements ColumnTypeValidate {
    @Override
    protected void checked(CubeColumnDto cubeColumnDto) {
        String choseValues = super.getCustomParam("choseValues");
        if (StringUtils.isBlank(choseValues)) {
            throw new CustomException(ColumnExceptionResponse.OPTION_VALUE_EMPTY);
        }
        cubeColumnDto.setMinLength(null);
        cubeColumnDto.setMinLength(null);
        cubeColumnDto.setMaxValue(null);
        cubeColumnDto.setMinValue(null);
        cubeColumnDto.setDecimalNum(null);
        ColumnExtTool.initCubeColumnExt(cubeColumnDto, "选项值", "choseValues", choseValues);
    }
}
